from pydantic import BaseModel
from datetime import datetime
from typing import Optional

# 创建知识卡片的基础模型
class KnowledgeCardBase(BaseModel):
    title: str
    summary: str
    html_content: str
    page_number: str
    material_id: int

# 创建知识卡片的请求模型
class KnowledgeCardCreate(KnowledgeCardBase):
    pass

# 更新知识卡片的请求模型
class KnowledgeCardUpdate(BaseModel):
    title: Optional[str] = None
    summary: Optional[str] = None
    html_content: Optional[str] = None
    page_number: Optional[str] = None

# 知识卡片的响应模型
class KnowledgeCard(BaseModel):
    id: int
    title: str
    summary: str
    html_content: str
    page_number: str
    material_title: str  # 替代 material_id
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True

class GenerateKnowledgeCardRequest(BaseModel):
    material_id: int
    window_size: Optional[int] = 2  #  # 默认窗口大小为2页
    overlap_size: Optional[int] = 1  # 默认重叠1页
